class Solution:
    def longestPalindrome(self, s: str) -> str:
        length = 1
        res = s[0]
        max_len = len(s)
        dp = [[False] * max_len for _ in range(max_len)]
        while length <= max_len:
            i = 0
            while i < max_len:
                j = i + length - 1
                if j >= max_len:
                    break
                if i == j:
                    dp[i][j] = True
                if length == 2 and s[i] == s[j]:
                    dp[i][j] = True
                if length > 2 and dp[i + 1][j - 1] and s[i] == s[j]:
                    dp[i][j] = True
                res = s[i : j + 1] if dp[i][j] and len(res) < len(s[i : j + 1]) else res
                i += 1
            length += 1
        return res


s = "bb"
solution = Solution()
result = solution.longestPalindrome(s)
print(f"Test 1: {result}")
